<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/views/include/taglib.jsp" %>

<head>
    <title>新建模型 - 模型管理</title>
    <meta name="decorator" content="form"/>
</head>
<!-- END HEAD -->

<body style="background: white;">
<!-- BEGIN CONTAINER -->
<div class="form-body" style="padding: 30px">
    <form:form id="inputForm" action="${ctx}/act/model/create" target="_blank" method="post">
        <div class="form-body">
            <div class="alert alert-danger display-hide">
                <button class="close" data-close="alert"></button>
                <i class="fa fa-close"></i> 表单填写时出现了一些问题，请仔细检查...
            </div>
            <div class="alert alert-success display-hide">
                <button class="close" data-close="alert"></button>
                <i class="fa fa-check"></i> 正在提交数据，请稍候...
            </div>
            <div class="form-group form-md-line-input">
                <select id="category" name="category" class="form-control required">
                    <c:forEach items="${fns:getDictList('act_category')}" var="dict">
                        <option value="${dict.value}">${dict.label}</option>
                    </c:forEach>
                </select>
                <label> 流程分类</label>
            </div>
            <div class="form-group form-md-line-input">
                <input id="name" name="name" type="text" class="form-control required"/>
                <label> 模块名称</label>
            </div>
            <div class="form-group form-md-line-input">
                <input id="key" name="key" type="text" class="form-control required"/>
                <label> 模块标识</label>
            </div>
            <div class="form-group form-md-line-input">
                <textarea id="description" name="description" class="form-control required"></textarea>
                <label> 模块描述</label>
            </div>
        </div>
    </form:form>

</div>
<!-- END CONTAINER -->

<%@include file="/views/include/foot.jsp" %>
<script type="text/javascript">
    var validateForm;
    function doSubmit() { // 回调函数，在编辑和保存动作时，供openDialog调用提交表单。
        if (validateForm.form()) {
            $("#inputForm").submit();
            return true;
        }
        return false;
    }

    $(document).ready(function () {
        validateForm = $("#inputForm").validate({
            errorElement: 'span',
            errorClass: 'help-inline border-red font-red',
            focusInvalid: false,
            errorContainer: "#messageBox",

            submitHandler: function (form) {
                loading('正在提交，请稍等...');
                form.submit();
            },
            errorPlacement: function (error, element) {
                $("#messageBox").text("输入有误，请先更正");
                if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
                    error.appendTo(element.parent().parent());
                } else {
                    error.insertAfter(element);
                }
            }
        });
    });
</script>
</body>
</html>